require 'fileutils'
require File.dirname(__FILE__) + '/.config.rb'

def checkRepoEnv()
    repoLog = `pod repo list`
    if $? != 0 then
        puts repoLog
        return
    end
    if repoLog.include?(REPO_NAME) then

        puts("#{SPEC_NAME}开始clone...")
        log = `cd;cd #{LOCAL_REP_PATH};git clone #{REMOTE_REP_PATH}/#{SPEC_NAME}.git;cd #{SPEC_NAME};git checkout master;git pull;git checkout -b master`
        puts log

        puts "更新#{SPEC_NAME}"
        puts `pod repo update #{REPO_NAME}`
        if $? != 0 then
            puts "更新#{SPEC_NAME}失败"
        else
            puts "更新#{SPEC_NAME}成功"
        end
    else
        puts `pod repo add #{REPO_NAME} #{REMOTE_REP_PATH}#{SPEC_NAME}.git`
        if $? != 0 then
            puts "！！！添加#{REPO_NAME}失败！！！"
        else
            puts "添加#{REPO_NAME}成功"
        end
    end
end
checkRepoEnv()